// 文章模块api封装
import request from '@/utils/request'
// 获取文章列表
export const getArticles = params =>{
    return request({
        method: 'GET',
        url: '/mp/v1_0/articles',
        // body参数用data设置
        // query参数用params设置
        // headers参数用headers设置
        params
    })
}
// 获取文章频道分类数据
export const getArticlesChannels = () =>{
    return request({
        method: 'GET',
        url: '/mp/v1_0/channels',
        // body参数用data设置
        // query参数用params设置
        // headers参数用headers设置
    })
}
// 删除文章
export const deleteArticle = articleId => {
    return request({
        method: 'DELETE',
        // 路径参数需要在url中传递
        url: `/mp/v1_0/articles/${articleId}`
    })
}
// 发布文章
export const addArticle = (data, draft = false) => {
    return request({
        method: 'POST',
        // 路径参数需要在url中传递
        url: '/mp/v1_0/articles',
        params: {
            draft // 是否存入草稿
        },
        data
    })
}
// 编辑、修改文章
 export const updateArticle = (articleId, data, draft = false) =>{
     return  request({
         method: 'PUT',
         url: `/mp/v1_0/articles/${articleId}`,
         params: {
             draft
         },
        data

     })
 }
 // 获取指定文章
 export const getArticle = articleId => {
     return request({
         method: 'GEt',
         url: `/mp/v1_0/articles/${articleId}`,

     })
 }
 //  修改文章评论状态
 export const updateCommentStatus = (articleId , allowComment)=> {
    return request({
        method: 'PUT',
        url: '/mp/v1_0/comments/status',
        params: {
            article_id: articleId
        },
        data: {
            allow_comment: allowComment
        }
    })
}
